home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CPPCLASS / OWLDEL / delBase.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-07-17  |  2.8 KB  |  114 lines

  1. unit delBase;
  2.  
  3. interface
  4.   uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  5.   Forms, ComOWL;
  6.  
  7. type
  8. TDelOwlControl = class(TControl)
  9.   private
  10.     { Private declarations }
  11.  
  12.      FOnMessage     : TMessageEvent;
  13.      procedure FOnMessageExported(aMsg, wParam : Word; lParam: Longint);
  14.        cdecl; export;
  15.  
  16.   protected
  17.     { Protected declarations }
  18.     OWLHelpControl : TCOMInterface;
  19.     procedure VisibleChanging; override;
  20.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  21.  
  22.   public
  23.     { Public declarations }
  24.       constructor Create(AOwner: TComponent); override;
  25.       destructor Destroy;    override;
  26.       procedure  Invalidate; override;
  27.       procedure  Repaint;    override;
  28.       procedure  Update;     override;
  29.   published
  30.     { Published declarations }
  31.  
  32.     property OnClick;
  33.     property OnDblClick;
  34.     property OnDragDrop;
  35.     property OnDragOver;
  36.     property OnEndDrag;
  37.     property OnMouseDown;
  38.     property OnMouseMove;
  39.     property OnMouseUp;
  40.     property Visible;
  41.   end;
  42.  
  43. implementation
  44.  
  45. function _COMClassConstructor(parentHWnd : hWnd):
  46.           TCOMInterface; cdecl; far; external 'OWLDEL'
  47.                   name '_COMCLASSCONSTRUCTOR';
  48.  
  49. procedure _COMClassDestructor(mySlider : TCOMInterface); cdecl;
  50.                      far;  external 'OWLDEL'
  51.                      name '_COMCLASSDESTRUCTOR';
  52.  
  53.  
  54.  
  55. constructor TDelOwlControl.Create(AOwner: TComponent);
  56. begin
  57.   inherited Create(AOwner);
  58.  
  59.   if (Owner is TWinControl) then
  60.       OWLHelpControl  := _COMClassConstructor(TWinControl(Owner).Handle);
  61.  
  62.   if OWLHelpControl = nil then abort;
  63.  
  64.   if not (csDesigning in ComponentState) then
  65.      OWLHelpControl.SetOnMessage(FOnMessageExported);
  66.  
  67.   Width    := 120;
  68.   Height   := 40;
  69.   {sync OWL and the VCL control}
  70.   Visible  := not Visible;
  71.   Visible  := not Visible;
  72. end;
  73.  
  74. destructor TDelOwlControl.Destroy;
  75. begin
  76.    _COMClassDestructor(OWLHelpControl);
  77.    OWLHelpControl := nil;
  78.   inherited Destroy;
  79. end;
  80. procedure  TDelOwlControl.Invalidate;
  81. begin
  82.   OWLHelpControl.Invalidate;
  83. end;
  84.  
  85. procedure  TDelOwlControl.Repaint;
  86. begin
  87.    OWLHelpControl.Repaint;
  88. end;
  89.  
  90. procedure  TDelOwlControl.Update;
  91. begin
  92.   OWLHelpControl.Update;
  93. end;
  94.  
  95. procedure TDelOwlControl.FOnMessageExported(aMsg, wParam : Word; lParam: Longint);
  96. begin
  97.   if (csDesigning in ComponentState) or
  98.      (csLoading in ComponentState)then Exit;
  99.   Perform(aMsg, wParam, lParam);
  100. end;
  101.  
  102. procedure TDelOwlControl.VisibleChanging;
  103. begin
  104.  OWLHelpControl.SetVisible(wordbool(not Visible));
  105. end;
  106.  
  107. procedure TDelOwlControl.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
  108. begin
  109.   inherited SetBounds(ALeft, ATop, AWidth, AHeight);
  110.   OWLHelpControl.SetBounds(ALeft, ATop, AWidth, AHeight);
  111. end;
  112.  
  113. end.
  114.